package com.yoo.ons.adapter

import android.app.Activity
import androidx.core.view.isVisible
import com.yoo.module_base.utils.GlideUtil
import com.yoo.ons.base.adpater.BaseRecyclerAdapter
import com.yoo.ons.databinding.ItemChooseGenderBinding
import com.yoo.ons.model.RegisterListModel

/**
 * 选择性别爱好
 */
class ChooseGenderAdapter(val activity:Activity,val callback:()->Unit):BaseRecyclerAdapter<RegisterListModel, ItemChooseGenderBinding>(ItemChooseGenderBinding::inflate) {
    override fun onBindView(
        holder: VH<ItemChooseGenderBinding>,
        position: Int,
        item: RegisterListModel?
    ) {
        item?.apply {
            GlideUtil.setImageView(item.iconUrl,holder.binding.itemPhoto,activity)
            holder.binding.itemChooseGenderCheck.isVisible=item.selected==1
            holder.binding.itemName.text=item.value
            holder.binding.root.setOnClickListener {
                item.selected = if (item.selected==1) 0 else 1
                notifyItemChanged(position)
                callback.invoke()
            }
        }
    }
}